import com.star.util.CodeUtil;
import com.star.util.Emai;
import com.star.util.MD5Util;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.junit.Test;

import java.io.*;
import java.net.URL;
import java.util.Date;

import static com.sun.xml.internal.ws.spi.db.BindingContextFactory.LOGGER;

/**
 * @Classname test
 * @Author Star
 * @Date 2021/4/27 - 8:11
 * @Description
 */
public class test {
    @Test
    public void test1() {
        System.out.println(MD5Util.md5("123456").toLowerCase().equals("e10adc3949ba59abbe56e057f20f883e"));
        //E10ADC3949BA59ABBE56E057F20F883E
    }

    @Test
    public void test2() throws Exception {
        System.out.println(Emai.email("1763166491@qq.com", "傻逼李俊","李俊","狗"));

//        String path = test.class.getResource("/emailTimeplet.html").getFile();//file:/E:/xxx/WEB-INF/classes/org/xxx/common/
//        System.out.println(path);
//        Document doc= Jsoup.parse(new URL("你要获取的网址"),(int型的等待超时毫秒数));
//        Document doc= Jsoup.parse(new URL("http://192.168.31.51:8080/index/email"),(10000));
//        String html = doc.toString();
//        System.out.println(html);
    }
    @Test
    public void test3() throws InterruptedException {
        int length = 8;
        for (int i = 0; i<5;i++){
            Thread.sleep(5);
            Long time = System.currentTimeMillis();
            String str = time.toString();
            System.out.println(str);
        }
    }
    /**
     * 获取对应pageName的html内容（本地eclipse里直接run）<br>
     * 字符流方式读取文件
     */
    private String getHtmlByPageName1(String pageName) {
        URL url = this.getClass().getClassLoader().getResource("public/templates/" + pageName + ".html");
        // File f = new
        // File("E:\\code_svn\\srp_trunk\\target\\classes\\templates\\404.html");
        StringBuffer sb = new StringBuffer();
        BufferedInputStream bis = null;
        try {
            File f = new File(url.toURI());
            FileInputStream fis = new FileInputStream(f);
            bis = new BufferedInputStream(fis);
            BufferedReader br = new BufferedReader(new InputStreamReader(fis));
            String s = "";
            while ((s = br.readLine()) != null) {
                sb.append(s).append("\n");
            }
        } catch (Exception e) {
        } finally {
            if (bis != null) {
                try {
                    bis.close();
                } catch (IOException e) {
                }
            }
        }
        return sb.toString();
    }
}

